home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
comm2
/
kms20src.lha
/
KMSC
/
msgbase3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-24
|
47KB
|
1,549 lines
/**********************************
* KMS *
**********************************
* ©1993 by BlackMagic Software *
**********************************
* *
**********************************/
#include <KMS/KMS.h>
Prototype UBYTE ReadMsg(UMSMsgNum, ULONG);
Prototype BOOL WriteMsg(UWORD, struct AreaNode *, STRPTR, STRPTR);
LONG DeleteFile(STRPTR);
/*****************************
* Externe Globale Variablen *
*****************************/
extern struct KMSBase *KMSBase;
extern struct LocalConfig *KMS_LC;
extern UMSAccount MyUMSAccount;
extern UMSAccount SysUMSAccount;
extern TEXT PathString[];
extern STRPTR PPArg;
extern STRPTR PPArg2;
extern STRPTR PPArg3;
extern STRPTR PPArg4;
extern STRPTR KMSVers;
extern UBYTE ShutDown, Plop;
extern TEXT KMSTempDat[];
extern TEXT BinaryName[];
extern TEXT BinaryPath[];
extern ULONG BinarySize;
extern UWORD AutoAct;
extern BOOL Spying;
/*********************
* Globale Variablen *
*********************/
UMSMsgNum Lastmsg = 0;
STRPTR RMsgText = NULL;
STRPTR RFromName = NULL;
STRPTR RFromAddr = NULL;
STRPTR RToName = NULL;
STRPTR RToAddr = NULL;
STRPTR RReplyGroup = NULL;
STRPTR RReplyName = NULL;
STRPTR RReplyAddr = NULL;
STRPTR RMsgID = NULL;
STRPTR RCreationDate = NULL;
STRPTR RReceiveDate = NULL;
STRPTR RReferID = NULL;
STRPTR RGroup = NULL;
STRPTR RSubject = NULL;
STRPTR RAttributes = NULL;
STRPTR RComments = NULL;
STRPTR ROrganization = NULL;
STRPTR RDistribution = NULL;
STRPTR RNewsReader = NULL;
struct MessageInfo RMsgInfo;
struct TagItem UMSReadTags[23] =
{
{UMSTAG_RMsgNum,0},
{UMSTAG_RMsgText,&RMsgText},
{UMSTAG_RFromName,&RFromName},
{UMSTAG_RFromAddr,&RFromAddr},
{UMSTAG_RToName,&RToName},
{UMSTAG_RToAddr,&RToAddr},
{UMSTAG_RMsgID,&RMsgID},
{UMSTAG_RCreationDate,&RCreationDate},
{UMSTAG_RReceiveDate,&RReceiveDate},
{UMSTAG_RReferID,&RReferID},
{UMSTAG_RGroup,&RGroup},
{UMSTAG_RSubject,&RSubject},
{UMSTAG_RAttributes,&RAttributes},
{UMSTAG_RComments,&RComments},
{UMSTAG_ROrganization,&ROrganization},
{UMSTAG_RDistribution,&RDistribution},
{UMSTAG_RReplyGroup,&RReplyGroup},
{UMSTAG_RReplyName,&RReplyName},
{UMSTAG_RReplyAddr,&RReplyAddr},
{UMSTAG_RNewsreader,&RNewsReader},
{UMSTAG_RMsgInfo,&RMsgInfo},
{TAG_DONE,0}
};
/***************************************
* Nachricht lesen *
***************************************
* I: Msg-Nummer, Flags *
* O: CTRL-C/X oder 0 *
***************************************/
/// "ReadMsg"
UBYTE ReadMsg(UMSMsgNum msgnum, ULONG flags)
{
UBYTE abbruch = 0;
BOOL fileattach = FALSE;
TEXT fname[LEN_DOSFILE+1];
TEXT fsizebuff[LEN_NUMBER+1];
ULONG fsize;
BOOL spymerk = FALSE;
static BOOL nnmsg = TRUE;
static BOOL nnarea = FALSE;
static BOOL nsarea = FALSE;
static UMSMsgNum merkmsg = 0;
if (flags == RF_RESET)
{
Lastmsg = 0;
nnmsg = TRUE;
nnarea = FALSE;
nsarea = FALSE;
KMS_LC->Session.CurrentUser->UserData.Flags &= ~UF_RMODE_RANGE;
return 0;
}
SelectArea(KMS_LC->Session.CurrentArea->AreaData.MBName);
if (!msgnum)
{
if (flags & RF_SAME && !(msgnum = Lastmsg))
SysMsg(NO_MSG_READ);
else if (flags & RF_NEW && !(msgnum = NextMsg(0, MLIST_NEW)))
{
if (!nnarea)
{
SysMsg(NO_NEXTNEW_MSG);
nnarea = TRUE;
}
else
{
ReadMsg(0,RF_RESET);
ListAreas(NULL,ALIST_WHOLE|ALIST_NEXTNEW);
}
}
else if (flags & RF_SEL && !(msgnum = NextMsg(Lastmsg, MLIST_SEL)))
{
if (!nsarea)
{
SysMsg(NO_NEXTSEL_MSG);
nsarea = TRUE;
}
else
{
ReadMsg(0,RF_RESET);
ListAreas(NULL,ALIST_WHOLE|ALIST_NEXTSEL);
}
}
else if (flags & RF_RANGE && !(msgnum = NextMsg(Lastmsg, MLIST_RRANGE)))
{
SysMsg(NO_NEXTRANGE_MSG);
KMS_LC->Session.CurrentUser->UserData.Flags &= ~UF_RMODE_RANGE;
}
else if (flags & RF_NEXT && !(msgnum = NextMsg(Lastmsg, MLIST_ALL)))
SysMsg(NO_NEXT_MSG);
else if (flags & RF_PREV && !(msgnum = PrevMsg(Lastmsg, MLIST_ALL)))
SysMsg(NO_PREV_MSG);
else if (flags & RF_NXTSEL && !(msgnum = NextMsg(Lastmsg, MLIST_SEL)))
SysMsg(NO_NEXTSEL_MSG);
else if (flags & RF_PRVSEL && !(msgnum = PrevMsg(Lastmsg, MLIST_SEL)))
SysMsg(NO_PREVSEL_MSG);
else if (flags & RF_FIRST && !(msgnum = NextMsg(0, MLIST_ALL)))
SysMsg(NO_MSG_FOUND);
else if (flags & RF_LAST && !(msgnum = PrevMsg(0, MLIST_ALL)))
SysMsg(NO_MSG_FOUND);
else if (flags & RF_NREPLY && !(msgnum = NextReply(Lastmsg)))
{
if (!nnmsg && !(flags & RF_NORMSG))
{
SysMsg(NO_NEXT_REPLY);
nnmsg = TRUE;
}
else
{
if (!(msgnum = NextMsg(0, MLIST_NEW)))
{
if (!nnarea)
{
SysMsg(NO_NEXTNEW_MSG);
nnarea = TRUE;
}
else
{
ReadMsg(0,RF_RESET);
ListAreas(NULL,ALIST_WHOLE|ALIST_NEXTNEW);
}
}
}
}
else if (flags & RF_PREPLY && !(msgnum = PrevReply(Lastmsg)))
SysMsg(NO_PREV_REPLY);
else if (flags & RF_RIGHT && !(msgnum = ChainRight(MyUMSAccount, Lastmsg)))
SysMsg(NO_RIGHT_REPLY);
else if (flags & RF_LEFT && !(msgnum = ChainLeft(MyUMSAccount, Lastmsg)))
SysMsg(NO_LEFT_REPLY);
else if (flags & RF_PARENT && !(msgnum = ChainUp(MyUMSAccount, Lastmsg)))
SysMsg(NO_PARENT_REPLY);
else if (flags & RF_CONT && !(msgnum = merkmsg))
SysMsg(NO_MARKED_MSG);
else if (flags & RF_ROOT)
{
if (msgnum = ChainUp(MyUMSAccount, Lastmsg))
{
UMSMsgNum msg;
while(msg = ChainUp(MyUMSAccount, msgnum))
msgnum = msg;
}
else
SysMsg(NO_PARENT_REPLY);
}
else if (flags & RF_DOWN)
{
UMSMsgNum msg;
if (msgnum = ChainDown(MyUMSAccount, Lastmsg))
while(msg = ChainLeft(MyUMSAccount, msgnum))
msgnum = msg;
if (!msgnum)
SysMsg(NO_DOWN_REPLY);
}
}
if (!msgnum)
return 0;
UMSReadTags[0].ti_Data = msgnum;
/* Msg nie dagewesen oder gelöscht? */
if (!ReadUMSMsg(MyUMSAccount, &UMSReadTags[0])
|| !(RMsgInfo.msgi_LoginStatus & KMSLSTATF_Visible))
{
SysMsg(MSG_NOT_FOUND);
FreeUMSMsg(MyUMSAccount, msgnum);
return 0;
}
/* Msg nicht in aktueller Gruppe? */
if (!(RMsgInfo.msgi_LoginStatus & KMSLSTATF_InGroup))
{
STRPTR rgroup = "";
if (RGroup)
rgroup = RGroup;
struct AreaNode *anode = AreaSearch(rgroup);
if (anode)
{
UBYTE curraccess = CheckAccess(anode);
if (curraccess & AACC_READ)
{
CreatePath(anode);
PPArg = PathString;
SysMsg(CROSS_REF);
if (YNRequest(CHANGE_GROUP, TRUE))
{
PPArg = NULL;
KMS_LC->Session.CurrentArea = anode;
KMS_LC->Session.CurrentAccess = curraccess;
SelectArea(anode->AreaData.MBName);
}
else
{
PPArg = NULL;
FreeUMSMsg(MyUMSAccount, msgnum);
return 0;
}
}
else
{
FreeUMSMsg(MyUMSAccount, msgnum);
PPArg = KMS_LC->Session.InputBuffer;
SysMsg(NO_READ_ACCESS);
PPArg = NULL;
return 0;
}
}
else
{
PPArg = rgroup;
SysMsg(INV_CROSS_REF);
PPArg = NULL;
FreeUMSMsg(MyUMSAccount, msgnum);
return 0;
}
}
/* Alles ok */
merkmsg = Lastmsg;
Lastmsg = msgnum;
nnmsg = FALSE;
nnarea = FALSE;
/* Header-Info aufbereiten */
TEXT up[2] = " ", down[2] = " ", left[2] = " ", right[2] = " ", local[2] = "*";
TEXT numbuff[5+1], lenbuff[5+1], subbuff[LEN_MAXLINE+1];
if (RMsgInfo.msgi_ChainUp)
up[0] = '^';
if (RMsgInfo.msgi_ChainDn)
down[0] = 'v';
if (RMsgInfo.msgi_ChainLt)
left[0] = '<';
if (RMsgInfo.msgi_ChainRt)
right[0] = '>';
if (RMsgInfo.msgi_GlobalStatus & UMSGSTATF_Exported)
local[0] = ' ';
STRPTR rfromname = "";
STRPTR rcreationdate = "";
STRPTR rtoname = "";
STRPTR rmsgtext = "\n";
STRPTR rsubject = "";
if (RFromName) rfromname = RFromName;
if (RCreationDate) rcreationdate = RCreationDate;
if (RToName) rtoname = RToName;
if (RMsgText) rmsgtext = RMsgText;
if (RSubject) rsubject = RSubject;
sprintf(numbuff, "%05ld", msgnum);
sprintf(lenbuff, "%5ld", strlen(rmsgtext));
strncpy(subbuff, rsubject, KMS_LC->Session.CurrentUser->UserData.LineLen - 20);
subbuff[KMS_LC->Session.CurrentUser->UserData.LineLen - 20] = '\0';
/* Spionieren unterbinden */
spymerk = Spying;
Spying = FALSE;
/* Nachrichten-Header-Info ausgeben */
KMS_LC->Session.LineCounter = 1;
PPArg = up; PPArg2 = rcreationdate;
ParsePrint(KMSBase->MsgHead[0], 0);
PPArg = left; PPArg2 = numbuff; PPArg3 = right; PPArg4 = rfromname;
ParsePrint(KMSBase->MsgHead[1], 0);
PPArg = down; PPArg2 = rtoname; PPArg3 = NULL; PPArg4 = NULL;
ParsePrint(KMSBase->MsgHead[2], 0);
PPArg = local; PPArg2 = lenbuff; PPArg3 = local; PPArg4 = subbuff;
ParsePrint(KMSBase->MsgHead[3], 0);
PPArg = NULL; PPArg2 = NULL; PPArg3 = NULL; PPArg4 = NULL;
TEXT umsflags[23];
if ((flags & RF_VERBOSE) || (KMS_LC->Session.CurrentUser->UserData.Flags & UF_HEAD_LONG))
{
UMSSet stat = RMsgInfo.msgi_UserStatus;
strcpy(umsflags, "U: --------- G: ------");
if (stat & UMSUSTATF_Archive)
umsflags[3] = 'A';
if (stat & UMSUSTATF_Junk)
umsflags[4] = 'J';
if (stat & UMSUSTATF_PostPoned)
umsflags[5] = 'P';
if (stat & UMSUSTATF_Selected)
umsflags[6] = 'S';
if (stat & UMSUSTATF_Old)
umsflags[7] = 'O';
if (stat & UMSUSTATF_WriteAccess)
umsflags[8] = 'W';
if (stat & UMSUSTATF_ReadAccess)
umsflags[9] = 'R';
if (stat & UMSUSTATF_ViewAccess)
umsflags[10] = 'V';
if (stat & UMSUSTATF_Owner)
umsflags[11] = 'O';
stat = RMsgInfo.msgi_GlobalStatus;
if (stat & UMSGSTATF_Deleted)
umsflags[16] = 'D';
if (stat & UMSGSTATF_Expired)
umsflags[17] = 'X';
if (stat & UMSGSTATF_Exported)
umsflags[18] = 'E';
if (stat & UMSGSTATF_Orphan)
umsflags[19] = 'O';
if (stat & UMSGSTATF_Link)
umsflags[20] = 'L';
if (stat & UMSGSTATF_HardLink)
umsflags[21] = 'H';
}
if (KMS_LC->Session.CurrentUser->UserData.Flags & UF_EMU_ANSI)
Print(OFF, PF_NOLF|PF_NOBRK);
KMS_LC->Session.LineCounter = 5;
if (!strcmp(KMS_LC->Session.CurrentArea->AreaData.MBName, "*KMS-GLOBAL*"))
{
if (RGroup)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[14], 0), MsgPrint(RGroup, 0);
else
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[14], 0), MsgPrint("-UMS-MAIL-", 0);
}
if (RMsgID)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[0], 0), MsgPrint(RMsgID, 0);
if (RReferID)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[1], 0), MsgPrint(RReferID, 0);
if (RFromAddr)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[2], 0), MsgPrint(RFromAddr, 0);
if (RToAddr)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[3], 0), MsgPrint(RToAddr, 0);
if (RReplyName)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[11], 0), MsgPrint(RReplyName, 0);
if (RReplyAddr)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[12], 0), MsgPrint(RReplyAddr, 0);
if (RReplyGroup)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[13], 0), MsgPrint(RReplyGroup, 0);
if (ROrganization)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[4], 0), MsgPrint(ROrganization, 0);
if ((flags & RF_VERBOSE) || (KMS_LC->Session.CurrentUser->UserData.Flags & UF_HEAD_LONG))
{
if (umsflags)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[5], 0), MsgPrint(umsflags, 0);
if (RNewsReader)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[6], 0), MsgPrint(RNewsReader, 0);
if (RAttributes)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[7], 0), MsgPrint(RAttributes, 0);
if (RDistribution)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[8], 0), MsgPrint(RDistribution, 0);
if (RComments)
MsgPrint("\n", 0), MsgParsePrint(KMSBase->MsgInfos[9], 0), MsgPrint(RComments, 0);
}
if (KMS_LC->Session.CurrentUser->UserData.Flags & UF_EMU_ANSI)
Print(OFF, PF_NOLF|PF_NOBRK);
/* Auf File-Attach prüfen */
STRPTR arg;
if (RAttributes)
{
if (arg = strstr(RAttributes, "KMS_FNAME:"))
{
fsize = 0;
*fname = '\0';
*fsizebuff = '\0';
/* Fileinfo besorgen */
/* "KMS_FNAME:abcd... KMS_FSIZE:12345..." */
sscanf(arg, "KMS_FNAME:%30s", fname);
if (arg = strstr(RAttributes, "KMS_FSIZE:"))
sscanf(arg, "KMS_FSIZE:%d", &fsize);
sprintf(fsizebuff, "%ld", fsize);
MsgPrint("\n\n", 0);
if (KMS_LC->Session.CurrentArea->AreaData.Type & ATYPE_FILES)
{
MsgParsePrint(KMSBase->MsgInfos[10], 0);
MsgPrint(fname, 0);
MsgPrint(" (", 0);
MsgPrint(fsizebuff, 0);
MsgPrint(" Bytes)", 0);
}
else
{
MsgParsePrint(KMSBase->MsgInfos[10], 0);
MsgPrint(fname, 0);
MsgPrint(" (", 0);
MsgPrint(fsizebuff, 0);
MsgPrint(" Bytes)", 0);
}
if (KMS_LC->Session.CurrentUser->UserData.Flags & UF_EMU_ANSI)
Print(OFF, PF_NOLF|PF_NOBRK);
fileattach = TRUE;
}
}
/* Nachrichten-Text ausgeben */
MsgPrint("\n\n", 0);
if (flags & RF_ROT13)
Rot13(rmsgtext);
WordWrap(rmsgtext, KMS_LC->Session.CurrentUser->UserData.LineLen, 0);
abbruch = MsgPrint(rmsgtext, MP_ATTRIB);
if (!abbruch)
if (rmsgtext[strlen(rmsgtext)-1] != '\n')
abbruch = MsgPrint("\n", 0);
/* Spionieren wieder erlaubt */
Spying = spymerk;
/* Nachricht als gelesen markieren -> Local 1 löschen */
UMSSelectTags(MyUMSAccount, UMSTAG_SelMsg, msgnum,
UMSTAG_SelWriteLocal, TRUE,
UMSTAG_SelUnset, KMSLSTATF_Unread,
TAG_DONE);
FreeUMSMsg(MyUMSAccount,msgnum);
if (abbruch == 1)
{
/* CRS LEFT */
AutoAct = ACTION_CRS_LEFT;
return 0;
}
else if (abbruch == 2)
{
/* CRS RIGHT */
AutoAct = ACTION_CRS_RIGHT;
return 0;
}
else if (abbruch == 3)
{
/* SHIFT CURSOR LEFT */
AutoAct = ACTION_LIST_CURRENT;
return 0;
}
else if (abbruch == 4)
{
/* SHIFT CURSOR RIGHT = Naechstes Brett mit neuen Msgs */
AutoAct = ACTION_SHIFT_CRS_RIGHT;
return 0;
}
else if (abbruch == 5)
{
/* SHIFT CURSOR UP = Zuletzt gelesene nochmal */
AutoAct = ACTION_SHIFT_CRS_UP;
return 0;
}
else if (abbruch == 6)
{
/* SHIFT CURSOR DOWN = Kommentar auf zuletzt gelesene */
AutoAct = ACTION_SHIFT_CRS_DOWN;
return 0;
}
else if (abbruch == 7)
{
/* CURSOR UP */
AutoAct = ACTION_LIST_CURRENT;
return 0;
}
if (fileattach)
{
if (!(KMS_LC->Session.CurrentArea->AreaData.Type & ATYPE_FILES))
{
PPArg = fname;
PPArg2 = fsizebuff;
SysMsg(FILEATTACH_MESSAGE);
PPArg = NULL;
PPArg2 = NULL;
}
}
return abbruch;
}
///
/***************************************
* Nachricht schreiben *
***************************************
* I: Flags, Area, Datei, Empfänger *
* O: Erfolg TRUE/FALSE *
***************************************/
/// "WriteMsg"
BOOL WriteMsg(UWORD flags, struct AreaNode *target, STRPTR infile, STRPTR toname)
{
TEXT buff[LEN_REALNAME+LEN_ADDRESS+1];
TEXT outbuff[LEN_PARSEOUT+1];
TEXT wcreationdate[20];
struct AreaNode *current = KMS_LC->Session.CurrentArea;
LONG error = 0;
STRPTR myorg;
STRPTR wmsgtext = "";
STRPTR wfromname = NULL;
STRPTR wtoname = NULL;
STRPTR wtoaddr = NULL;
STRPTR wreplyname = NULL;
STRPTR wreplyaddr = NULL;
STRPTR wreplygroup = NULL;
STRPTR wattributes = NULL;
STRPTR wsubject = "";
STRPTR wgroup = "";
if (target)
current = target;
else if (flags & WF_PRIV)
{
TakeASem(FALSE);
current = SetArea(1);
DropASem();
}
if (!(CheckAccess(current) & AACC_WRITE))
{
PPArg = KMS_LC->Session.InputBuffer;
SysMsg(NO_WRITE_ACCESS);
PPArg = NULL;
return FALSE;
}
if (flags & (WF_REPLY|WF_RESEND|WF_EDIT|WF_FORWARD))
{
if (!Lastmsg)
{
SysMsg(NO_MSG_READ);
return FALSE;
}
UMSReadTags[0].ti_Data = Lastmsg;
if (!ReadUMSMsg(MyUMSAccount,&UMSReadTags[0]))
{
SystemError("WriteMsg", "ReadUMSMsg");
FreeUMSMsg(MyUMSAccount, Lastmsg);
return FALSE;
}
if (flags & (WF_RESEND|WF_EDIT))
{
if (!(RMsgInfo.msgi_UserStatus & UMSUSTATF_Owner))
{
SysMsg(MSG_NOT_OWNED);
FreeUMSMsg(MyUMSAccount, Lastmsg);
return FALSE;
}
}
}
/* Msg-Header belegen */
if (flags & (WF_NEW|WF_FORWARD))
{
if ((current->AreaData.Type & ATYPE_PRIVATE) || (current->AreaData.WriteFlag & AWF_TONAME))
{
/* ToName : Bei pers. Nachrichten oder oeffentl., wenn verlangt */
if (toname)
{
strncpy(buff, toname, sizeof(buff)-1);
buff[sizeof(buff)-1] = '\0';
}
else
*buff = '\0';
GetAlias(buff, GA_NAME, LEN_REALNAME);
if ((!strlen(buff) && (current->AreaData.Type & ATYPE_PRIVATE))
|| (strlen(buff) && !(wtoname = strdup(buff)) && (current->AreaData.Type & ATYPE_PRIVATE)))
{
if (flags & WF_FORWARD)
FreeUMSMsg(MyUMSAccount, Lastmsg);
GetAlias(NULL, GA_RESET, 0);
return FALSE; /* Keine priv. Mail ohne Adressat */
}
}
if (!(flags & WF_BINARY) && (current->AreaData.Type & ATYPE_PRIVATE))
{
/* ToAddr : Nur bei persoenlichen Nachrichten */
/* (Binaries nur lokal!) */
*buff = '\0';
GetAlias(buff, GA_ADDRESS, LEN_ADDRESS);
if (strlen(buff))
{
wtoaddr = strdup(buff);
if (!wtoaddr)
{
if (flags & WF_FORWARD)
FreeUMSMsg(MyUMSAccount, Lastmsg);
GetAlias(NULL, GA_RESET, 0);
if (wtoname)
free(wtoname);
return FALSE;
}
}
}
}
else if (flags & WF_REPLY)
{
if (current->AreaData.Type & ATYPE_PRIVATE)
{
/* Evt. Reply-To berücksichtigen */
if (RReplyName)
wtoname = strdup(RReplyName);
else if (RFromName)
wtoname = strdup(RFromName);
if (RReplyAddr)
wtoaddr = strdup(RReplyAddr);
else if (RFromAddr)
wtoaddr = strdup(RFromAddr);
if (RReplyName || RReplyAddr)
{
PPArg = RReplyName;
PPArg2 = RReplyAddr;
SysMsg(REPLY_TO);
PPArg = NULL;
PPArg2 = NULL;
}
}
else if (RFromName && (current->AreaData.WriteFlag & AWF_TONAME))
wtoname = strdup(RFromName);
if (KMS_LC->Session.CurrentUser->UserData.Flags & UF_EXTSEND)
{
TEXT wtonamebuff[LEN_REALNAME+1];
if (wtoname)
{
strncpy(wtonamebuff, wtoname, LEN_REALNAME);
wtonamebuff[LEN_REALNAME] = '\0';
free(wtoname);
wtoname = NULL;
}
else
*wtonamebuff = '\0';
GetAlias(NULL, GA_RESET, 0);
if ((current->AreaData.Type & ATYPE_PRIVATE) || (current->AreaData.WriteFlag & AWF_TONAME))
GetAlias(wtonamebuff, GA_NAME, LEN_REALNAME);
if ((!strlen(wtonamebuff) && (current->AreaData.Type & ATYPE_PRIVATE))
|| (strlen(wtonamebuff) && !(wtoname = strdup(wtonamebuff)) && (current->AreaData.Type & ATYPE_PRIVATE)))
{
if (flags & WF_FORWARD)
FreeUMSMsg(MyUMSAccount, Lastmsg);
GetAlias(NULL, GA_RESET, 0);
return FALSE;
}
if (current->AreaData.Type & ATYPE_PRIVATE)
{
TEXT wtoaddrbuff[LEN_ADDRESS+1];
if (wtoaddr)
{
strncpy(wtoaddrbuff, wtoaddr, LEN_ADDRESS);
wtoaddrbuff[LEN_ADDRESS] = '\0';
free(wtoaddr);
wtoaddr = NULL;
}
else
*wtoaddrbuff = '\0';
GetAlias(wtoaddrbuff, GA_ADDRESS, LEN_ADDRESS);
if (strlen(wtoaddrbuff) && !(wtoaddr = strdup(wtoaddrbuff)))
{
if (flags & WF_FORWARD)
FreeUMSMsg(MyUMSAccount, Lastmsg);
GetAlias(NULL, GA_RESET, 0);
if (wtoname)
free(wtoname);
return FALSE;
}
}
}
}
else /* if (flags & (WF_RESEND|WF_EDIT)) */
{
if (RToName)
wtoname = strdup(RToName);
if (RToAddr)
wtoaddr = strdup(RToAddr);
}
/* Alias-Puffer freigeben */
GetAlias(NULL, GA_RESET, 0);
/* Erstell-Datum */
time_t zeit = time(NULL);
struct tm *tp = localtime(&zeit);
strftime(wcreationdate, 19, "%d %b %y %H:%M:%S", tp);
/* Gruppenname */
wgroup = current->AreaData.MBName;
/* Evt. Followup-To berücksichtigen */
if (RReplyGroup && (flags & WF_REPLY) && strlen(wgroup))
{
struct AreaNode *anode = AreaSearch(RReplyGroup);
if (anode)
{
UBYTE curraccess = CheckAccess(anode);
if (curraccess & AACC_WRITE)
{
CreatePath(anode);
PPArg = PathString;
SysMsg(FOLLOWUP_TO);
PPArg = NULL;
wgroup = RReplyGroup;
}
}
}
/* Subject */
if (!(flags & (WF_RESEND|WF_EDIT)))
{
TEXT rsubject[LEN_CMDINPUT+1];
if (!(flags & WF_NEW))
{
if (RSubject)
{
if (!(flags & WF_FORWARD) && strncmp(RSubject, "Re:", 3) && strncmp(RSubject, "RE:", 3)
&& strncmp(RSubject, "re:", 3)
&& !(current->AreaData.WriteFlag & AWF_NORE))
strcpy(rsubject, "Re: ");
else
*rsubject = '\0';
strncat(rsubject, RSubject, LEN_CMDINPUT-strlen(rsubject));
rsubject[LEN_CMDINPUT] = '\0';
}
else
*rsubject = '\0';
if ((flags & WF_REPLY) && target)
{
strncat(rsubject, " [", LEN_CMDINPUT-strlen(rsubject));
strncat(rsubject, KMS_LC->Session.CurrentArea->AreaData.MBName, LEN_CMDINPUT-strlen(rsubject));
strncat(rsubject, "]", LEN_CMDINPUT-strlen(rsubject));
rsubject[LEN_CMDINPUT] = '\0';
}
}
if (flags & WF_NEW)
{
if (flags & WF_BINARY)
CmdInput(NULL, PROMPT_BINSHORT, NULL, NULL, LEN_SUBJECT, INF_PROMPT);
else
CmdInput(NULL, PROMPT_SUBJ, NULL, NULL, LEN_SUBJECT, INF_PROMPT);
}
else
CmdInput(NULL, PROMPT_SUBJ, NULL, rsubject, LEN_SUBJECT, INF_PROMPT|INF_DEFBUF);
if (Plop || ShutDown || !strlen(KMS_LC->Session.InputBuffer))
{
if (flags & (WF_REPLY|WF_FORWARD))
FreeUMSMsg(MyUMSAccount, Lastmsg);
if (flags & (WF_NEW|WF_FORWARD))
{
if (wtoname)
free(wtoname);
if (wtoaddr)
free(wtoaddr);
}
return FALSE;
}
wsubject = (STRPTR)malloc((size_t)(strlen(KMS_LC->Session.InputBuffer)+1));
if (wsubject)
strcpy(wsubject, KMS_LC->Session.InputBuffer);
}
else /* if (flags & (WF_RESEND|WF_EDIT)) */
wsubject = RSubject;
/* Nachrichten-Text erfassen */
if (!(flags & WF_BINARY) || YNRequest(QUERY_BINLONG, TRUE))
{
STRPTR rmsgtext = "\n";
if (RMsgText)
rmsgtext = RMsgText;
if (flags & WF_REPLY)
{
CreateComment(rmsgtext, flags);
AddSignature();
}
else if (flags & WF_RESEND)
CreateResendForward(rmsgtext, WF_RESEND);
else if (flags & WF_EDIT)
CreateResendForward(rmsgtext, WF_EDIT);
else if (flags & WF_FORWARD)
CreateResendForward(rmsgtext, WF_FORWARD);
else if (infile)
CreatePrivImport(infile);
else
{
DeleteFile(KMSTempDat);
AddSignature();
}
STRPTR editor;
TEXT cfgstring[20];
if (KMS_LC->Device & DEV_CONSOLE)
strcpy(cfgstring, "KMS.coneditor");
else
strcpy(cfgstring, "KMS.remoteeditor");
if ((KMS_LC->Session.CurrentUser->UserData.Flags & UF_SCREEN_ED) && (editor = ReadUMSConfigTags(SysUMSAccount, UMSTAG_CfgName, cfgstring, TAG_DONE)))
{
CreatePath(current);
PPArg = KMSTempDat;
PPArg2 = PathString;
StdStringParse(editor, outbuff, LEN_PARSEOUT);
PPArg = NULL;
PPArg2 = NULL;
FreeUMSConfig(SysUMSAccount, editor);
error = SystemCall(outbuff);
}
else if (flags & (WF_NEW|WF_REPLY))
LineEditor(KMSTempDat);
if (!error)
{
struct stat stat_buf;
error = stat(KMSTempDat, &stat_buf);
FILE *msgdat;
if (error == 0 && (msgdat = fopen(KMSTempDat, "r")))
{
wmsgtext = (STRPTR)malloc((size_t)(stat_buf.st_size+1));
if (wmsgtext)
{
fread(wmsgtext, 1, stat_buf.st_size, msgdat);
wmsgtext[stat_buf.st_size] = '\0';
}
fclose(msgdat);
}
/* Evt. ROT13 kodieren */
if (flags & WF_ROT13)
Rot13(wmsgtext);
}
}
/* Nachricht abspeichern */
ULONG writetags[39];
UBYTE t = 0;
if (!error)
{
if ((!(current->AreaData.Type & ATYPE_PRIVATE) || !wtoaddr) && current->AreaData.WriteFlag & AWF_PSEUDO)
writetags[t++] = UMSTAG_WFromName, writetags[t++] = KMS_LC->Session.CurrentUser->UserData.Name;
if (wtoname)
writetags[t++] = UMSTAG_WToName, writetags[t++] = wtoname;
if (wtoaddr)
writetags[t++] = UMSTAG_WToAddr, writetags[t++] = wtoaddr;
writetags[t++] = UMSTAG_WCreationDate, writetags[t++] = wcreationdate;
if (wsubject && strlen(wsubject))
writetags[t++] = UMSTAG_WSubject, writetags[t++] = wsubject;
if (flags & WF_REPLY)
{
if (RMsgID)
writetags[t++] = UMSTAG_WReferID, writetags[t++] = RMsgID;
writetags[t++] = UMSTAG_WChainUp, writetags[t++] = Lastmsg;
}
else if (flags & (WF_RESEND|WF_EDIT|WF_FORWARD))
{
if (RReferID)
writetags[t++] = UMSTAG_WReferID, writetags[t++] = RReferID;
if (RAttributes)
{
wattributes = strdup(RAttributes);
writetags[t++] = UMSTAG_WAttributes, writetags[t++] = wattributes;
}
}
if (!(flags & (WF_RESEND|WF_EDIT|WF_FORWARD)))
{
if (flags & WF_BINARY)
{
TEXT attrline[10+LEN_DOSFILE+1+10+LEN_NUMBER+1];
writetags[t++] = UMSTAG_WAttributes;
sprintf(attrline, "KMS_FNAME:%s KMS_FSIZE:%ld", BinaryName, BinarySize);
wattributes = strdup(attrline);
writetags[t++] = wattributes;
}
}
sprintf(buff,"KMS.originstr%d", current->AreaData.OriginStr);
if (myorg = ReadUMSConfigTags(SysUMSAccount, UMSTAG_CfgName, buff, TAG_DONE))
writetags[t++] = UMSTAG_WOrganization, writetags[t++] = myorg;
if (strlen(wgroup))
writetags[t++] = UMSTAG_WGroup, writetags[t++] = wgroup;
if (KMSVers)
writetags[t++] = UMSTAG_WNewsreader, writetags[t++] = KMSVers;
writetags[t++] = UMSTAG_WMsgText, writetags[t++] = wmsgtext;
writetags[t] = TAG_DONE;
}
BOOL sendit = FALSE;
LONG res;
UBYTE tag;
if (!error && (KMS_LC->Session.CurrentUser->UserData.Flags & UF_EXTSEND))
{
while(!error && !sendit)
{
if (wattributes && strlen(wattributes))
{
PPArg = wattributes;
SysMsg(CURR_MSG_ATTRIBS);
PPArg = NULL;
}
if (wreplyname && strlen(wreplyname))
{
PPArg = wreplyname;
PPArg2 = wreplyaddr;
SysMsg(CURR_REPLY_TO);
PPArg = NULL;
PPArg2 = NULL;
}
if (wreplygroup && strlen(wreplygroup))
{
PPArg = wreplygroup;
SysMsg(CURR_FOLLOWUP_TO);
PPArg = NULL;
}
res = CmdInput(NULL, SEND_OPTS, "0123459", "9", 1, INF_PROMPT|INF_NUMERIC);
if (Plop || ShutDown)
error = 1;
else if (res == 0) /* Abbruch */
error = 1;
else if (res == 9) /* Senden */
sendit = TRUE;
else if (res == 1) /* Reply-To */
{
if (wreplyname)
{
free(wreplyname);
wreplyname = NULL;
if (wreplyaddr)
free(wreplyaddr);
wreplyaddr = NULL;
tag = 0;
while(writetags[tag] != UMSTAG_WReplyName && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == UMSTAG_WReplyName)
writetags[tag++] = TAG_IGNORE, writetags[tag] = NULL;
tag = 0;
while(writetags[tag] != UMSTAG_WReplyAddr && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == UMSTAG_WReplyAddr)
writetags[tag++] = TAG_IGNORE, writetags[tag] = NULL;
}
else
{
*buff = '\0';
GetAlias(buff, GA_NAME, LEN_REALNAME);
if (strlen(buff))
{
wreplyname = strdup(buff);
if (wreplyname)
{
tag = 0;
while(writetags[tag] != UMSTAG_WReplyName && writetags[tag] != TAG_IGNORE && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WReplyName, writetags[t++] = wreplyname;
writetags[t] = TAG_DONE;
}
else
writetags[tag++] = UMSTAG_WReplyName, writetags[tag] = wreplyname;
*buff = '\0';
GetAlias(buff, GA_ADDRESS, LEN_ADDRESS);
if (strlen(buff))
{
wreplyaddr = strdup(buff);
if (wreplyaddr)
{
tag = 0;
while(writetags[tag] != UMSTAG_WReplyAddr && writetags[tag] != TAG_IGNORE && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WReplyAddr, writetags[t++] = wreplyaddr;
writetags[t] = TAG_DONE;
}
else
writetags[tag++] = UMSTAG_WReplyAddr, writetags[tag] = wreplyaddr;
}
}
}
}
GetAlias(NULL, GA_RESET, 0);
}
}
else if (res == 2) /* FollowUp-To */
{
if (wreplygroup)
{
free(wreplygroup);
wreplygroup = NULL;
tag = 0;
while(writetags[tag] != UMSTAG_WReplyGroup && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == UMSTAG_WReplyGroup)
writetags[tag++] = TAG_IGNORE, writetags[tag] = NULL;
}
else
{
struct AreaNode *anode;
*PathString = '\0';
strcpy(KMS_LC->Session.InputBuffer," ");
while(strlen(KMS_LC->Session.InputBuffer) && stricmp(PathString, KMS_LC->Session.InputBuffer))
{
CmdInput(NULL, PROMPT_HKF_ADDPATH, NULL, PathString, LEN_KMSPATH, INF_PROMPT|INF_UPCASE|INF_DEFBUF);
if (Plop || ShutDown)
{
error = 1;
*KMS_LC->Session.InputBuffer = '\0';
}
if (strlen(KMS_LC->Session.InputBuffer))
{
if (anode = ChangeArea(KMS_LC->Session.InputBuffer))
{
if (anode->AreaData.ID != 1)
CreatePath(anode);
}
else
SysMsg(INVALID_PATH);
}
else
error = 1;
}
if (!error)
{
wreplygroup = (STRPTR)malloc((size_t)(strlen(anode->AreaData.MBName)+1));
if (wreplygroup)
{
strcpy(wreplygroup, anode->AreaData.MBName);
tag = 0;
while(writetags[tag] != UMSTAG_WReplyGroup && writetags[tag] != TAG_IGNORE && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WReplyGroup, writetags[t++] = wreplygroup;
writetags[t] = TAG_DONE;
}
else
writetags[tag++] = UMSTAG_WReplyGroup, writetags[tag] = wreplygroup;
}
}
}
}
else if (res == 3 || res == 4 || res == 5) /* receipt-request / file-attach / Dringend */
{
STRPTR attribstring;
STRPTR newwattrib, temp, arg;
BOOL found = FALSE;
if (res == 3)
attribstring = "RECEIPT-REQUEST";
else if (res == 4)
attribstring = "FILE-ATTACH";
else
attribstring = "URGENT";
if (wattributes)
temp = strdup(wattributes);
else
temp = strdup("");
if (temp)
{
newwattrib = (STRPTR)malloc(strlen(wattributes)+1);
if (newwattrib)
{
*newwattrib = '\0';
for(arg = strtok(temp, " \t"); arg; arg = strtok(NULL, " \t"))
{
if (!stricmp(arg, attribstring))
found = TRUE;
else
{
if (strlen(newwattrib))
strcat(newwattrib, " ");
strcat(newwattrib, arg);
}
}
if (found)
{
free(wattributes);
wattributes = newwattrib;
}
else
{
FILE *fh = NULL;
BOOL doit;
TEXT dosbuff[LEN_DOSPATH+1];
free(newwattrib);
newwattrib = NULL;
if (res == 4) /* file-attach */
{
if (wsubject)
strcpy(KMS_LC->Session.InputBuffer, wsubject);
else
*KMS_LC->Session.InputBuffer = '\0';
do
{
if (KMS_LC->Device & DEV_CONSOLE)
{
strncpy(dosbuff, KMS_LC->Session.InputBuffer, LEN_DOSPATH);
dosbuff[LEN_DOSPATH] = '\0';
}
else if (!strchr(KMS_LC->Session.InputBuffer, ':') && !strchr(KMS_LC->Session.InputBuffer, '/'))
{
strcpy(dosbuff, KMSBase->UserDir);
strcat(dosbuff, KMS_LC->Session.CurrentUser->UserData.Name);
ConvertSpace(dosbuff);
strcat(dosbuff, "/");
strncat(dosbuff, KMS_LC->Session.InputBuffer, LEN_DOSFILE);
dosbuff[LEN_DOSPATH] = '\0';
}
else
*dosbuff = '\0';
if (*dosbuff && (fh = fopen(dosbuff, "r")))
{
fclose(fh);
doit = TRUE;
}
else
{
SysMsg(FILE_NOT_FOUND);
doit = FALSE;
}
if (!doit)
{
strcpy(dosbuff, KMS_LC->Session.InputBuffer);
if (KMS_LC->Device & DEV_CONSOLE)
CmdInput(NULL, PROMPT_FILENAME, " ,%*?#~[]()!\"\\", dosbuff, LEN_DOSPATH, INF_PROMPT|INF_DEFBUF|INF_EXCLUDE);
else
CmdInput(NULL, PROMPT_FILENAME, " /:,%*?#~[]()!\"\\", dosbuff, LEN_DOSFILE, INF_PROMPT|INF_DEFBUF|INF_EXCLUDE);
}
} while(!doit && *KMS_LC->Session.InputBuffer);
if (doit)
{
if (wsubject)
free(wsubject);
wsubject = strdup(dosbuff);
if (wsubject)
{
tag = 0;
while(writetags[tag] != UMSTAG_WSubject && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WSubject, writetags[t++] = wsubject;
writetags[t] = TAG_DONE;
}
else
writetags[++tag] = wsubject;
doit = TRUE;
}
else
doit = FALSE;
}
}
if (doit)
{
newwattrib = (STRPTR)malloc(strlen(wattributes)+1+strlen(attribstring)+1);
if (newwattrib)
{
strcpy(newwattrib, wattributes);
if (strlen(newwattrib))
strcat(newwattrib, " ");
strcat(newwattrib, attribstring);
}
free(wattributes);
wattributes = newwattrib;
}
}
}
free(temp);
}
if (!wattributes || !strlen(wattributes))
{
tag = 0;
while(writetags[tag] != UMSTAG_WAttributes && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == UMSTAG_WAttributes)
writetags[tag] = TAG_IGNORE, writetags[tag+1] = NULL;
if (wattributes)
free(wattributes);
wattributes = NULL;
}
else
{
tag = 0;
while(writetags[tag] != UMSTAG_WAttributes && writetags[tag] != TAG_IGNORE && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WAttributes, writetags[t++] = wattributes;
writetags[t] = TAG_DONE;
}
else
writetags[tag++] = UMSTAG_WAttributes, writetags[tag] = wattributes;
}
}
}
}
else if (!error)
sendit = YNRequest(SEND_REALLY, TRUE);
if (!sendit)
error = 1;
while(!error && sendit)
{
sendit = FALSE;
UMSMsgNum written;
if (written = WriteUMSMsg(MyUMSAccount, (struct TagItem *)&writetags[0]))
{
sprintf(buff, "%ld", written);
PPArg = buff;
SysMsg(MSG_WRITTEN);
PPArg = NULL;
/* Local-Flags 0 (sichtb.) und 2 (in Gruppe) setzen */
UMSSelectTags(MyUMSAccount, UMSTAG_SelMsg, written,
UMSTAG_SelWriteLocal, TRUE,
UMSTAG_SelSet, KMSLSTATF_Visible|KMSLSTATF_InGroup,
TAG_DONE);
sendRexxCmd("CHECKMAIL", NULL, NULL, NULL, NULL, "KMS");
}
else if (UMSErrNum(MyUMSAccount) == UMSERR_NoReader)
{
PPArg = wtoname;
PPArg2 = wtoaddr;
SysMsg(INVALID_ADDRESS);
PPArg = NULL;
PPArg2 = NULL;
if (YNRequest(SEND_RETRY, TRUE))
{
*buff = '\0';
GetAlias(buff, GA_NAME, LEN_REALNAME);
if (strlen(buff))
{
if (wtoname)
free(wtoname);
wtoname = strdup(buff);
if (wtoname)
{
tag = 0;
while(writetags[tag] != UMSTAG_WToName && writetags[tag] != TAG_DONE)
tag++;
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WToName, writetags[t++] = wtoname;
writetags[t] = TAG_DONE;
}
else
writetags[++tag] = wtoname;
if (flags & WF_BINARY)
sendit = TRUE;
else
{
*buff = '\0';
GetAlias(buff, GA_ADDRESS, LEN_ADDRESS);
tag = 0;
while(writetags[tag] != UMSTAG_WToAddr && writetags[tag] != TAG_IGNORE && writetags[tag] != TAG_DONE)
tag++;
if (strlen(buff))
{
if (wtoaddr)
free(wtoaddr);
wtoaddr = strdup(buff);
if (wtoaddr)
{
if (writetags[tag] == TAG_DONE)
{
writetags[t++] = UMSTAG_WToAddr, writetags[t++] = wtoaddr;
writetags[t] = TAG_DONE;
}
else
writetags[tag++] = UMSTAG_WToAddr, writetags[tag] = wtoaddr;
sendit = TRUE;
}
}
else
{
if (wtoaddr)
{
free(wtoaddr);
wtoaddr = NULL;
}
if (writetags[tag] == UMSTAG_WToAddr)
{
writetags[tag++] = TAG_IGNORE;
writetags[tag] = NULL;
}
sendit = TRUE;
}
}
}
}
GetAlias(NULL, GA_RESET, 0);
}
else
error = 1;
}
else
SystemError("WriteMsg", "WriteUMSMsg");
}
/* Speicher wieder freigeben */
if (flags & (WF_REPLY|WF_RESEND|WF_EDIT|WF_FORWARD))
FreeUMSMsg(MyUMSAccount, Lastmsg);
if (myorg)
FreeUMSConfig(SysUMSAccount, myorg);
if (wmsgtext && strlen(wmsgtext))
free(wmsgtext);
if (wreplyname)
free(wreplyname);
if (wreplyaddr)
free(wreplyaddr);
if (wreplygroup)
free(wreplygroup);
if (wattributes)
free(wattributes);
if (!(flags & (WF_RESEND|WF_EDIT)))
{
if (wsubject && strlen(wsubject))
free(wsubject);
}
if (wtoname)
free(wtoname);
if (wtoaddr)
free(wtoaddr);
if (error)
return FALSE;
else
return TRUE;
}
///